# Contributor: Adrian Siekierka <kontakt@asie.pl>
# Maintainer: Adrian Siekierka <kontakt@asie.pl>
pkgname=openttd
pkgver=1.10.2
pkgrel=0
pkgdesc="Open source version of the Transport Tycoon Deluxe simulator"
url="https://www.openttd.org"
arch="all"
license="GPL-2.0-or-later"
makedepends="fontconfig-dev freetype-dev icu-dev libpng-dev lzo-dev
	sdl2-dev xz-dev zlib-dev"
checkdepends="openttd-opengfx"
subpackages="$pkgname-doc $pkgname-lang::noarch"
source="https://cdn.openttd.org/openttd-releases/$pkgver/openttd-$pkgver-source.tar.xz"

build() {
	# OpenTTD's builtin strip does not work when cross-compiling,
	# but it will be done automatically later in the package build.
	./configure \
		--build="$CBUILD" \
		--host="$CHOST" \
		--disable-strip \
		--prefix-dir=/usr \
		--binary-dir=bin \
		--install-dir="$pkgdir" \
		--with-sdl \
		--with-zlib \
		--with-liblzma \
		--with-liblzo2 \
		--with-freetype \
		--with-fontconfig \
		--without-icu
	make
}

check() {
	make test
}

package() {
	make install
}

lang() {
	pkgdesc="$pkgdesc (localizations)"

	cd "$pkgdir"
	mkdir -p "$subpkgdir"/usr/share/games/openttd/lang
	find usr/share/games/openttd/lang/ ! -name 'english.lng' -type f \
		-exec mv {} "$subpkgdir"/{} \;
}

sha512sums="03de85449a458c76c07d8a28c34f72bc95ab0652c666e5925da43746cdd4e95b0d66360b6e214d1df33f11b5346da2e3b9ca6832ac6628c7d6e5e0a791881683  openttd-1.10.2-source.tar.xz"
